<?php

class Retailer_Backend_Block_Adminhtml_Sales_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
  protected function _prepareForm()
  {
      $form = new Varien_Data_Form();
      $this->setForm($form);
      $form->setDataObject(Mage::registry('backend_data'));
      //$session = Mage::getSingleton('adminhtml/session');
      $dataModel = Mage::registry('backend_data');
      $billingAddress = $dataModel->getBillingAddress();
      $shippingAddress = $dataModel->getShippingAddress();
      $fieldset = $form->addFieldset('billing_form', array('legend'=>Mage::helper('backend')->__('Billing information')));

//      $fieldset->addField('billing', 'label', array(
//          'label'     => Mage::helper('backend')->__('Billing Information'), //Mage::getModel('admin/user')->load($session->getId())->getId()
//          'class'     => 'required-entry',
//          'required'  => false,
//          'name'      => 'billing',
//          //'value'     => "{$billingAddress->getData('firstname')} {$billingAddress->getData('lastname')}",
//      ));
      $fieldset->addField('billing_name', 'label', array(
          'label'     => Mage::helper('backend')->__('Billed to:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'billing_name',
          'value'     => "{$billingAddress->getData('firstname')} {$billingAddress->getData('lastname')}",
      ));
      $fieldset->addField('company', 'label', array(
          'label'     => Mage::helper('backend')->__('Company:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'company',
          'value'     => "{$billingAddress->getData('company')}",
      ));
      $fieldset->addField('street', 'label', array(
          'label'     => Mage::helper('backend')->__('Street Address:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'street',
          'value'     => "{$billingAddress->getData('street')}",
      ));
      $fieldset->addField('city', 'label', array(
          'label'     => Mage::helper('backend')->__('City:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'city',
          'value'     => "{$billingAddress->getData('city')}",
      ));
      $fieldset->addField('state', 'label', array(
          'label'     => Mage::helper('backend')->__('State:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'state',
          'value'     => "{$billingAddress->getData('region')}",
      ));
      $fieldset->addField('postcode', 'label', array(
          'label'     => Mage::helper('backend')->__('ZIP code:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'postcode',
          'value'     => "{$billingAddress->getData('postcode')}",
      ));
      $fieldset->addField('country', 'label', array(
          'label'     => Mage::helper('backend')->__('Country:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'country',
          'value'     => "{$billingAddress->getData('country_id')}",
      ));
      $fieldset->addField('telephone', 'label', array(
          'label'     => Mage::helper('backend')->__('Telephone Number:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'telephone',
          'value'     => "{$billingAddress->getData('telephone')}",
      ));
      $fieldset->addField('fax', 'label', array(
          'label'     => Mage::helper('backend')->__('Telephone Number:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'fax',
          'value'     => "{$billingAddress->getData('fax')}",
      ));
      $fieldset2 = $form->addFieldset('shipping_form', array('legend'=>Mage::helper('backend')->__('Shipping information')));
//      $fieldset2->addField('shipping', 'label', array(
//          'label'     => Mage::helper('backend')->__('Billing Information'), //Mage::getModel('admin/user')->load($session->getId())->getId()
//          'class'     => 'required-entry',
//          'required'  => false,
//          'name'      => 'shipping',
//          //'value'     => "{$billingAddress->getData('firstname')} {$billingAddress->getData('lastname')}",
//      ));
      $fieldset2->addField('shipping_name', 'label', array(
          'label'     => Mage::helper('backend')->__('Shipped to:'),
          'required'  => false,
          'name'      => 'shipping_name',
          'value'     => "{$shippingAddress->getData('firstname')} {$shippingAddress->getData('lastname')}",
      ));
      $fieldset2->addField('companysh', 'label', array(
          'label'     => Mage::helper('backend')->__('Company:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'companysh',
          'value'     => "{$shippingAddress->getData('company')}",
      ));
      $fieldset2->addField('streetsh', 'label', array(
          'label'     => Mage::helper('backend')->__('Street Address:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'streetsh',
          'value'     => "{$shippingAddress->getData('street')}",
      ));
      $fieldset2->addField('citysh', 'label', array(
          'label'     => Mage::helper('backend')->__('City:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'citysh',
          'value'     => "{$shippingAddress->getData('city')}",
      ));
      $fieldset2->addField('statesh', 'label', array(
          'label'     => Mage::helper('backend')->__('State:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'statesh',
          'value'     => "{$shippingAddress->getData('region')}",
      ));
      $fieldset2->addField('postcodesh', 'label', array(
          'label'     => Mage::helper('backend')->__('ZIP code:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'postcodesh',
          'value'     => "{$shippingAddress->getData('postcode')}",
      ));
      $fieldset2->addField('countrysh', 'label', array(
          'label'     => Mage::helper('backend')->__('Country:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'country',
          'value'     => "{$shippingAddress->getData('country_id')}",
      ));
      $fieldset2->addField('telephonesh', 'label', array(
          'label'     => Mage::helper('backend')->__('Telephone Number:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'telephone',
          'value'     => "{$shippingAddress->getData('telephone')}",
      ));
      $fieldset2->addField('faxsh', 'label', array(
          'label'     => Mage::helper('backend')->__('Telephone Number:'), //Mage::getModel('admin/user')->load($session->getId())->getId()
          'class'     => 'required-entry',
          'required'  => false,
          'name'      => 'fax',
          'value'     => "{$shippingAddress->getData('fax')}",
      ));
//      $fieldset->addField('username', 'label', array(
//          'label'     => Mage::helper('backend')->__('Username(security reasons)'),
//          'required'  => true,
//          'name'      => 'username',
//      ));
//
//     $fieldset->addField('password', 'label', array(
//          'label'     => Mage::helper('backend')->__('Password(security reasons)'),
//          'required'  => true,
//          'name'      => 'password',
//      ));
//
//      $fieldset->addField('status', 'select', array(
//          'label'     => Mage::helper('backend')->__('Status'),
//          'name'      => 'status',
//          'values'    => array(
//              array(
//                  'value'     => 1,
//                  'label'     => Mage::helper('backend')->__('Enabled'),
//              ),
//
//              array(
//                  'value'     => 2,
//                  'label'     => Mage::helper('backend')->__('Disabled'),
//              ),
//          ),
//      ));
//
//      $fieldset->addField('content', 'editor', array(
//          'name'      => 'content',
//          'label'     => Mage::helper('backend')->__('Content'),
//          'title'     => Mage::helper('backend')->__('Content'),
//          'style'     => 'width:700px; height:500px;',
//          'wysiwyg'   => false,
//          'required'  => false,
//      ));
                
     
      if ( Mage::getSingleton('adminhtml/session')->getBackendData() )
      {
          //$form->setValues(Mage::getSingleton('adminhtml/session')->getBackendData());
          //Mage::getSingleton('adminhtml/session')->setBackendData(null);
      } elseif ( Mage::registry('backend_data') ) {
          //$form->setValues(Mage::registry('backend_data')->getData());
      }
      return parent::_prepareForm(); 
  }
}